<?php
	function pagelinks(){
		gloabl $
		echo "共计<font color=\"#ff0000\">$totalRows1</font>条记录";
		echo "<font color=\"#ff0000\">".$currentpage."</font>"."/".$page."页 ";
		echo "<div class='pages'>";
        $pre = $currentpage - 1;
        $next = $currentpage + 1;
        $maxpages = 5;
        $pagepre = 1;
        if($currentpage==1){
        	echo "<a href='".$_SERVER['PHP_SELF']."'>首页</a> ";
        	echo "<a href='".$_SERVER['PHP_SELF']."'><</a> ";
        }else{
        	echo "<a href='".$_SERVER['PHP_SELF']."'>首页</a> ";
        	echo "<a href='".$_SERVER['PHP_SELF'].'?currentpage='.$pre."'><</a> ";
        }
        if($maxpages>=$page) 
        {$pgstart = 1;$pgend = $page;}
        elseif(($currentpage-$pagepre-1+$maxpages)>$page)
        {$pgstart = $page - $maxpages + 1;$pgend = $page;}
        else{
        $pgstart=(($currentpage<=$pagepre)?1:($currentpage-$pagepre));
        $pgend=(($pgstart==1)?$maxpages:($pgstart+$maxpages-1));
        }
        for($pg=$pgstart;$pg<=$pgend;$pg++){
        if($pg == $currentpage) echo "<a href=\"".$_SERVER['PHP_SELF']."?currentpage=$pg\"><font color=\"#ff0000\">$pg</font></a> ";
        else echo "<a href=\"".$_SERVER['PHP_SELF']."?currentpage=$pg\">$pg</a> ";
        }
        if($currentpage == $page){
        	echo "<a href='".$_SERVER['PHP_SELF'].'?currentpage='.$page."'>></a> ";
        	echo "<a href='".$_SERVER['PHP_SELF'].'?currentpage='.$page."'>最后一页</a> ";
        }else{
        	echo "<a href='".$_SERVER['PHP_SELF'].'?currentpage='.$next."'>></a> ";
        	echo "<a href='".$_SERVER['PHP_SELF'].'?currentpage='.$page."'>最后一页</a> ";
        }
	    echo "</div>";
	}
?>